﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://www.codeplex.com/EmlenMud
using System;
using System.Runtime.Serialization;
using System.ComponentModel;

namespace BrainTechLLC
{
	[Serializable]
    [DataContract]
    public class TimeInfoData : IComparable<ITimeInfoData>, ITimeInfoData
	{
		public TimeInfoData() { }

        [DataMember]
		public DateTime Time { get; set; }

		public TimeSpan ElapsedTime
		{
			get { return Globals.TimeFlow.CurrentTime.Subtract(Time); }
            set { Time = Globals.TimeFlow.StartTime.Add(value); }
		}

		public TimeSpan TimeBetween(ITimeInfoData firstEventTime, ITimeInfoData secondEventTime)
		{
			return secondEventTime.Time.Subtract(firstEventTime.Time);
		}

		public int CompareTo(ITimeInfoData other) { return Time.CompareTo(other.Time); }
		public object Clone() { return new TimeInfoData() { Time = this.Time }; }
	}
}
